home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Frameworks
/
TransSkel++ 305
/
Interface
/
TransSkel++.h
next >
Wrap
Text File
|
1996-06-28
|
16KB
|
346 lines
/*
** TransSkel++.h
**
** Class definitions for the TransSkel++ module.
** Include this file in your TransSkel++ source files.
**
**
** Fred Dushin
** email: fadushin@top.cis.syr.edu
**
** Release 3.04 May 1, 1996
** See release notes for details of changes.
*/
#if !defined TRANS_SKEL_PP_H
#define TRANS_SKEL_PP_H
extern "C"{
#include <TransSkel.h>
}
//======================================================================/
// The CApplObj Class /
// /
// Base Class: none /
// Methods: • Error(Str255 errorStr, short code); /
// Handle errors in TransSkel++ /
// /
// Description: Every class in TransSkel++ is a subclass /
// of the ApplObj base class. This permits all objects /
// to inherit the error handling facilities defined therein. /
//======================================================================/
enum SkelppErrorCode{
Skelpp_noErr,
Skelpp_fatalErr,
Skelpp_ErrBase
};
class CApplObj{
public:
// Constructors and Destructors
CApplObj( void ){}
protected:
// Error handlers
virtual void Error( Str255 errStr, short c );
private:
void FatalAlert( Str255 str );
short FakeAlert( StringPtr s1, StringPtr s2,
StringPtr s3, StringPtr s4,
short nButtons, short defButton,
short cancelButton,
StringPtr t1, StringPtr t2, StringPtr t3 );
};
//======================================================================/
// The CApplication Class /
// /
// Base Class: CApplObj Class /
// Methods: • Run(void); /
// Run the application /
// • doEventHook(EventRecord *evt); /
// Respect the host's event hook /
// • doSuspendResume(Boolean inForeground); /
// Handle suspend/resume events /
// • doIdle(void); /
// Handle idle events /
// /
// Description: Every program must have exactly one CApplication /
// class (or subclass) instance, which is pointed to by the static /
// pointer sApplication. Typically, a programmer will define /
// a subclass of the CApplication class for his or her purposes, /
// making it a container for all global storage in the program. /
// /
// The CApplication class constructor adds an event hook for /
// inspecting events before being processed by TransSkel. This /
// event hook is necessary for proper handling of menu events, /
// since TransSkel does not have anything for menus like the /
// property list it supports for windows and dialogs. /
//======================================================================/
class CApplication : public CApplObj{
public:
// Constructors and Destructors
CApplication( SkelInitParamsPtr initParams );
virtual ~CApplication( void );
// Event Handlers
virtual void doSuspendResume( Boolean inForeground ){}
virtual void doIdle( void ){}
virtual Boolean doEventHook( EventRecord *evt ){ return false; }
virtual void doMenuHook( void ){}
virtual void doAE( EventRecord *evt ){}
// other methods
void Run( void ){ SkelEventLoop(); }
};
//======================================================================/
// The CMenuObj Class /
// /
// Base Class: CApplObj Class /
// Methods: • doSelect(short item); /
// Handle selection events in menu /
// /
// Member variables: /
// • MenuHandle menu; (protected) /
// A handle to the QD menu structure /
// /
// Description: The CMenuObj class is a base class for all /
// menus (apple, menubar, hierarchical, etc.). /
// Why is this class here? To treat apple menus and /
// menubar menus consistently through the event hook. /
// /
// Programmers should use class destructors in place of /
// TransSkel clobber procs, so no clobber methods are /
// defined for this class /
//======================================================================/
class CMenuObj : public CApplObj{
public:
// Constructors and Destructors
CMenuObj( void ){ menu = nil; }
virtual ~CMenuObj( void ){}
// Event Handlers
virtual void doSelect( short item ){}
//Accessors
MenuHandle GetMenuHandle( void ){ return menu; }
protected:
MenuHandle menu;
};
//======================================================================/
// The CMenu Class /
// /
// Base Class: CMenuObj Class /
// Methods: • doSelect(short item); /
// Handle item selections in menu /
// /
// Member variables: /
// • MenuHandle menu; (protected) /
// A handle to the QD menu structure /
// /
// Description: The CMenu class is used for standard (anything /
// not an apple) menu handling. Users of TransSkel++ will typically /
// create subclasses of the CMenu class for each menu in the /
// application (e.g., CFileMenu, CEditMenu, etc.) Because TransSkel /
// treates the Apple menu specially, a special CAppleMenu class /
// is defined below. /
//======================================================================/
class CMenu : public CMenuObj{
public:
// Constructors and Destructors
CMenu( void ){}
CMenu( short menuID, Boolean subMenu, Boolean drawBar );
virtual ~CMenu( void );
// Event Handlers
virtual void doSelect( short item ){}
};
//======================================================================/
// The CAppleMenu Class /
// /
// Base Class: CMenuObj Class /
// Methods: • doSelect(short item); /
// Handle item selections in Apple menu /
// /
// Description: The CAppleMenu class is used for managing the /
// apple menu. Because TransSkel treats the apple menu specially, /
// (with SkelApple), a special class constructor is needed. Also, /
// TransSkel provides for no destructors for Apple menus, so /
// the CAppleMenu class has no clobber method. /
//======================================================================/
class CAppleMenu : public CMenuObj{
public:
// Constructors and Destructors
CAppleMenu( const StringPtr items );
virtual ~CAppleMenu( void );
// Event Handlers
virtual void doSelect( short item ){}
};
//======================================================================/
// The CWindow Class /
// /
// Base Class: CApplObj Class /
// Methods: • doMouseClick(Point where, long when, short modifiers);/
// Handle mouse clicks in window /
// • doKeyClick(short c, short code, short modifiers); /
// Handle key clicks in window /
// • doUpdate(Boolean resized); /
// Handle Update events in window /
// • doActivate(Boolean active); /
// Handle Activate events in window /
// • doClose(void); /
// Handle closing window (default method /
// hides window via HideWindow()) /
// • doIdle(void); /
// Handle idle events in window /
// • doShow(void); /
// Display window (Calls Show/SelectWindow()) /
// • GetWindowPtr(void); /
// Returns WindowPtr to QD window struct /
// /
// Member variables: /
// • WindowPtr wind; (protected) /
// A pointer to the QD window structure /
// /
// Description: The CWindow class is the base class for all window /
// objects in TransSkel++. Users will typically create subclasses /
// of the CWindow class (e.g., CDrawWindow, CStatusWindow, etc.) /
// and override any of the above methods and/or create new ones. /
//======================================================================/
class CWindow : public CApplObj{
public:
// Constructors and Destructors
CWindow( void ){}
CWindow( Ptr wStorage,
Rect *boundsRect,
Str255 title,
Boolean visible,
int procID,
WindowPtr behind,
Boolean goAway,
long refCon,
Boolean frontIdle );
CWindow( short windID,
Ptr wStorage,
WindowPtr behind,
Boolean frontIdle );
virtual ~CWindow( void );
// Event Handlers
virtual void doMouseClick( Point where, long when,
short modifiers ){}
virtual void doKeyClick( short c, short code,
short modifiers){}
virtual void doUpdate( Boolean resized ){}
virtual void doActivate( Boolean active ){}
virtual void doClose( void ){ HideWindow( wind ); }
virtual void doIdle( void ){}
virtual void doShow( void );
// Accessors
WindowPtr GetWindowPtr( void ){ return wind; }
protected:
void SavePort( void ){ GetPort( &oldPort );
SetPort( wind ); }
void RestorePort( void ){ SetPort( oldPort ); }
WindowPtr wind;
private:
WindowPtr oldPort;
};
//======================================================================/
// The CDialog Class /
// /
// Base Class: CApplObj Class /
// Methods: • doFilter(EventRecord *evt, short *item); /
// dialog filter proc /
// • doSelect(short item); /
// Handle item selections in dialog /
// • doClose(void); /
// Handle closing dialog (default method /
// hides window via HideWindow()) /
// • doShow(void); /
// Display dialog (Calls Show/SelectWindow()) /
// • GetDialogPtr(void); /
// Returns DialogPtr to QD dialog struct /
// /
// Member variables: /
// • DialogPtr dlog; (protected) /
// A pointer to the QD dialog structure /
// /
// Description: The CDialog class is the base class for all dialog /
// objects in TransSkel++. Users will typically create subclasses /
// of the CDialog class (e.g., CAboutDialog, CSettingDialog, etc.) /
// and override any of the above methods and/or create new ones. /
//======================================================================/
class CDialog : public CApplObj{
public:
// Constructors and Destructors
CDialog( void ){}
CDialog( Ptr dStorage,
Rect *boundsRect,
Str255 title,
Boolean visible,
int procID,
DialogPtr behind,
Boolean goAway,
long refCon,
Handle items);
CDialog( short dlogID, Ptr wStorage, WindowPtr behind );
virtual ~CDialog( void );
// Event Handlers
virtual Boolean doFilter( EventRecord *evt, short *item )
{ return false; }
virtual void doSelect( short item ){}
virtual void doClose( void )
{ HideWindow( dlog ); }
virtual void doShow( void );
// Accessors
DialogPtr GetDialogPtr( void )
{ return dlog; }
protected:
void SavePort( void ){ GetPort( &oldPort );
SetPort( dlog ); }
void RestorePort( void ){ SetPort( oldPort ); }
DialogPtr dlog;
private:
DialogPtr oldPort;
};
//-- FUNCTION PROTOTYPES -----------------------------------------------/
CWindow * GetCWindow(WindowPtr wind);
CDialog * GetCDialog(DialogPtr dlog);
#endif